<!--
 * @jixuanyu: jixuanyu
 * @Date: 2022-05-31 17:39:02
 * @LastEditors: jixuanyu
 * @Description: file content
-->
<template>
  <z-button type="primary" @click="showModal">Open Modal</z-button>
</template>
<script>
import { defineComponent, ref } from 'vue'
import { Modal } from '../../../../lib/index'
export default defineComponent({
  setup() {
    const visible = ref(false)
    const showModal = () => {
      Modal.confirm({
        title: 'Do you want to delete these items?',
        content:
          'When clicked the OK button, this dialog will be closed after 1 second',
        onOk() {
          return new Promise((resolve, reject) => {
            setTimeout(Math.random() > 0.5 ? resolve : reject, 1000)
          }).catch(() => console.log('Oops errors!'))
        },
        // eslint-disable-next-line @typescript-eslint/no-empty-function
        onCancel() {},
      })
    }
    return {
      visible,
      showModal,
    }
  },
})
</script>
